package com.oa.works.config.shiro;

import org.springframework.stereotype.Component;

/**
 * 缓存token的媒介类
 * @date 2021/10/13 18:53
 * @author Qin
 */
@Component
public class ThreadLocalToken {
    private ThreadLocal<String> local = new ThreadLocal<>();

     /**
     *写入token
     */
    public void setToken(String token){
        local.set(token);
    }

    /**
     * 获取token
     */
    public String getToken(){
        return local.get();
    }

    /**
     * 清除token/删除绑定的值
     */
    public void clear(){
        local.remove();
    }
}
